﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.Skins;
using DevExpress.LookAndFeel;
using DevExpress.UserSkins;
using DevExpress.XtraEditors;
using DotSpatial.Data;


namespace DotSpatial.Plugins.ExtensionManager
{
    public partial class DataExtensionForm : XtraForm
    {
        private Dictionary<string, IDataProvider> dataSource;
        public DataExtensionForm()
        {
            InitializeComponent();


        }
        public void InitGrid(Dictionary<string, IDataProvider> preferredProviders, IEnumerable<IDataProvider> availableProviders)
        {
            this.dataSource = preferredProviders;
            var gridDataList = new BindingList<KeyValuePair<string, IDataProvider>>();
            foreach (KeyValuePair<string, IDataProvider> keyValuePairString in preferredProviders)
            {
                gridDataList.Add(keyValuePairString);
            }
            foreach (IDataProvider provider in availableProviders)
            {

                var extensions = DotSpatial.Data.DataManager.DefaultDataManager.GetSupportedExtensions(provider.DialogReadFilter);
                foreach (var ext in extensions)
                {
                    gridDataList.Add(new KeyValuePair<string, IDataProvider>(ext, provider));
                }

                // Todo: need to figure out read vs write for providers
            }
            gridControl.DataSource = gridDataList;
        }
    }
}
